﻿// -------------------------------------------------------------------------------------------------------------------------------
// <copyright file="TestSolveWithHighTriangle.cs" company="Exul">
//     Copyright (c) Exul. All rights reserved.
// </copyright>
// <author>
//     Exul
// </author>
// -------------------------------------------------------------------------------------------------------------------------------

namespace ExulLibrary.Mathematics.LinearAlgebra.Sequential.Tests.CrcsSparseSymmetricMatrixTest.DoubleExtensions
{
    #region Usings

    using ExulLibrary.Mathematics.LinearAlgebra.Sequential.DoubleExtensions;

    using NUnit.Framework;

    #endregion

    /// <summary>
    ///     Test suite for <see cref="CrcsSparseSymmetricMatrixExtensions.SolveWithHighTriangle"/>.
    /// </summary>
    [TestFixture]
    [Category("ExulLibrary.Mathematics.LinearAlgebra.Sequential.DoubleExtensions.CrcsSparseSymmetricMatrixExtensions")]
    public sealed class TestSolveWithHighTriangle
    {
        #region Methods

        #region public

        /// <summary>
        ///     Tests the method when parameters are valid.
        /// </summary>
        [Test]
        public void WhenParametersAreValid()
        {
            // Arrange:
            // Matrix:
            // 1 0 3 6
            // 0 2 5 0
            // 3 5 4 7
            // 6 0 7 8
            var matrix = new CrcsSparseSymmetricMatrix<double>(
                begins: new[] { 0, 0, 0, 2, 4 },
                indexes: new[] { 0, 1, 0, 2 },
                diagonalData: new double[] { 1, 2, 4, 8 },
                triangleData: new double[] { 3, 5, 6, 7 });
            var rightHandPart = new DenseVector<double>(new double[] { 63010, 5100, 71000, 10000 });

            // Act
            matrix.SolveWithHighTriangle(rightHandPart);

            // Assert
            Assert.That(rightHandPart.Values, Is.EquivalentTo(new double[] { 10, 100, 1000, 10000 }));
        }

        #endregion

        #endregion
    }
}